package com.ruoyi.active.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.active.domain.CfActivityImage;
import com.ruoyi.active.service.ICfActivityImageService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 活动照片/视频Controller
 * 
 * @author zhangbiao
 * @date 2024-06-04
 */
@RestController
@RequestMapping("/activityImage")
public class CfActivityImageController extends BaseController
{
    @Autowired
    private ICfActivityImageService cfActivityImageService;

    /**
     * 查询活动照片/视频列表
     */
    @RequiresPermissions("active:activityImage:list")
    @GetMapping("/list")
    public TableDataInfo list(CfActivityImage cfActivityImage)
    {
        startPage();
        List<CfActivityImage> list = cfActivityImageService.selectCfActivityImageList(cfActivityImage);
        return getDataTable(list);
    }

    /**
     * 导出活动照片/视频列表
     */
    @RequiresPermissions("active:activityImage:export")
    @Log(title = "活动照片/视频", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CfActivityImage cfActivityImage)
    {
        List<CfActivityImage> list = cfActivityImageService.selectCfActivityImageList(cfActivityImage);
        ExcelUtil<CfActivityImage> util = new ExcelUtil<CfActivityImage>(CfActivityImage.class);
        util.exportExcel(response, list, "活动照片/视频数据");
    }

    /**
     * 获取活动照片/视频详细信息
     */
    @RequiresPermissions("active:activityImage:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(cfActivityImageService.selectCfActivityImageById(id));
    }

    /**
     * 新增活动照片/视频
     */
    @RequiresPermissions("active:activityImage:add")
    @Log(title = "活动照片/视频", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CfActivityImage cfActivityImage)
    {
        return toAjax(cfActivityImageService.insertCfActivityImage(cfActivityImage));
    }

    /**
     * 修改活动照片/视频
     */
    @RequiresPermissions("active:activityImage:edit")
    @Log(title = "活动照片/视频", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CfActivityImage cfActivityImage)
    {
        return toAjax(cfActivityImageService.updateCfActivityImage(cfActivityImage));
    }

    /**
     * 删除活动照片/视频
     */
    @RequiresPermissions("active:activityImage:remove")
    @Log(title = "活动照片/视频", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(cfActivityImageService.deleteCfActivityImageByIds(ids));
    }
}
